package cn.hznc.controller.uploadfilestrategy;

import cn.hutool.core.util.ObjectUtil;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author：Administrator
 * @Date：2024/2/28 11:16
 */
public class DownFileContext{

    private DownFileStrategy downFileStrategy;

    public DownFileContext(){

    }

    public DownFileContext(DownFileStrategy downFileStrategy){
        this.downFileStrategy = downFileStrategy;
    }

    public void downloadFileByStrategy(HttpServletResponse response , String fileName , Integer flag){
        if(ObjectUtil.isNotNull(flag) && flag == 1){
            this.downFileStrategy = new DownloadMinio();
            downFileStrategy.downFile(response , fileName);
        }else if(ObjectUtil.isNotNull(flag) && flag == 2){
            this.downFileStrategy = new DownloadLocal();
            downFileStrategy.downFile(response , fileName);
        }
    }
}
